<? FoundryView::includeTpl( 'adminMain:header' ) ?>

<script type="text/javascript" src="<?=Foundry::config('webpath')?>/javascript/admin/editToolBar.js"></script>
<script type="text/javascript" src="<?=Foundry::config('webpath')?>/javascript/admin/imageBucketRules.js"></script>

<div id="mainContent">

	<h2>Image Manager</h2>
	
	<a href="<?=FoundryView::helperLinkTo('imageBucketAdmin/upload')?>" class="actionLink">
		<img src="<?=Foundry::config('webpath')?>/images/admin/add.png" />
		new image</a>
	<span id="actionMessage"></span>
	
	<div class="actionForm">
		<form method="post" action="<?=FoundryView::helperLinkTo('imageBucketAdmin/edit')?>/<?=$this->data['image']->uid?>">

		<div class="cellLeft">
	
			<input type="hidden" name="k" value="<?=$this->data['key']?>" />
			<label for="imageName">Name</label>
			<input type="text" value="<?=$this->data['image']->name?>" disabled="true" /><p />
			
			<label for="imageCredit">Credit</label>
			<input type="text" name="imageCredit" value="<?=$this->data['image']->credit?>" /><p />

			<label for="imageSource">Source</label>
			<input type="text" name="imageSource" value="<?=$this->data['image']->source?>" /><p />
			
			<label for="imageCaption">Caption</label>
			<div id="imageCaptionToolBar"></div>
			<script type="text/javascript">
				ToolBar.create( 'imageCaptionToolBar',
					'imageCaption' );
			</script>

			<textarea rows="5" cols="55" name="imageCaption" id="imageCaption"><?=$this->data['image']->caption?></textarea><p />
			
			<label for="imageDescription">Description</label>
			<div id="imageDescriptionToolBar"></div>
			<script type="text/javascript">
				ToolBar.create( 'imageDescriptionToolBar',
					'imageDescription' );
			</script>

			<textarea rows="5" cols="55" name="imageDescription" id="imageDescription"><?=$this->data['image']->description?></textarea><p />
			<p />
			<input type="submit" value="Save" />
			<a href="<?=FoundryView::helperLinkTo( 'imageBucketAdmin/' )?>" class="cancelLink">
				Cancel</a>
		</div>
		<div class="cellRight">
			<label>Preview</label>
			<img src="<?=$this->data['image']->filePath?><?=$this->data['image']->thumbNail?>" alt="<?=$this->data['image']->name?>" style="border: 1px solid #000; margin:2px; padding:2px;" id="imageThumbContainer<?=$this->data['image']->uid?>" /><br />
			<span class="highlight">
				<a href="<?=$this->data['image']->filePath?><?=$this->data['image']->name?>" target="new" title="Preview this image"><img src="<?=Foundry::config('webpath')?>/images/admin/picture.png" border="0" /></a>
				<a href="#" id="rotateLeft" title="Rotate Counter-Clockwise" for="<?=$this->data['image']->uid?>"><img src="<?=Foundry::config('webpath')?>/images/admin/arrow_rotate_anticlockwise.png" border="0" /></a>
				<a href="#" id="rotateRight" title="Rotate Clockwise" for="<?=$this->data['image']->uid?>"><img src="<?=Foundry::config('webpath')?>/images/admin/arrow_rotate_clockwise.png" border="0" /></a>
				<!--<a href="#" id="crop" title="Crop" for="<?=$this->data['image']->uid?>"><img src="<?=Foundry::config('webpath')?>/images/admin/shape_handles.png" border="0" /></a>-->
			</span>
			<p />
		
			<label for="imagePublished">Publication Status</label>
			<input type="checkbox" name="imagePublished" value="1" <?php if( $this->data['image']->published ) { echo 'checked="checked"'; } ?> /> Image is published<p />

			<label for="imageCategory">Category</label>
			<select name="imageTagID[]" multiple="multiple">
			<?php
			
				$tagModel = FoundryModel::factory( 'tag' );
				$tags = $tagModel->find( 'order by *name' );
				foreach( $tags as $tag ) {
					echo '<option value="'.$tag->uid.'"';
					
					if( is_array( $this->data['postTags'] ) && in_array( $tag->uid, $this->data['postTags'] ) ) {
						echo ' selected="selected"';
					}
					
					echo '>'.$tag->name.'</option>';
				}
			?>
			</select><p />
			
		</div>
		<br class="cellBottom" />
		
		</form>
	</div>		
</div>
<?php if( FoundryRequest::get( 'msg' ) == 'sv' ) : ?>
<script type="text/javascript">
	actionMessage( 'Image Saved' );
</script>
<?php endif ?>

<? FoundryView::includeTpl( 'adminMain:footer' ) ?>